<%--处理管理订单的页面--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!-- layUI的核心CSS文件 -->
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/layui-v2.5.7/layui/css/layui.css"/>
    <!-- layUI的核心JS文件 -->
    <script src="${pageContext.request.contextPath}/static/layui-v2.5.7/layui/layui.js" type="text/javascript"
            charset="UTF-8"></script>
<%--        回到顶部的样式--%>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/css/toTop.css">

    <title>我的订单</title>
</head>
<body>
<%--回到顶部--%>
<i class="layui-icon layui-icon-up toTop"></i>
<script src="${pageContext.request.contextPath}/static/js/toTop.js">
</script>





<script>
    //JavaScript代码区域
    layui.use('element', function () {
        let element = layui.element;
    });
</script>
<script>
    layui.use('form', function () {
        let form = layui.form;
    });
    layui.use('layer', function () {
        let layer = layui.layer;
    });
</script>
<!-- 头部导航栏 -->
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo"><a style="color: #009688;">龙洞闲置购物系统</a></div>

        <!-- 头部区域（可配合layui已有的水平导航） -->

        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item">
                <a href="ShowALLGoods">首页</a>
            </li>
            <li class="layui-nav-item">
                我的订单
            </li>
        </ul>
        <%@include file="../common/head.jsp" %>
    </div>
</div>

<%-- 选项卡 --%>
<div class="layui-tab">
    <ul class="layui-tab-title">
        <li class="layui-this">我买到的</li>
        <li>我卖出的</li>
    </ul>

    <div class="layui-tab-content">
        <%-- 我买到的 --%>
        <div class="layui-tab-item layui-show">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 25px">
                <legend style="margin-left: 50px;">我买到的</legend>
            </fieldset>

            <div class="layui-row">
                <div class="layui-col-md10">
                    <table class="layui-table">
                        <colgroup>
                            <col width="50">
                            <col width="200">
                            <col width="300">
                            <col width="180">
                            <col width="300">
                            <col width="100">
                            <col width="80">
                            <col width="80">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>商品</th>
                            <th>商品描述</th>
                            <th>交易时间</th>
                            <th>交易详情</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <c:if test="${orderslist.size() == 0}">
                                <td colspan="7" style="text-align: center;height: 100px;">还没有买过商品哦~</td>
                            </c:if>
                            <c:forEach var="orders1" items="${orderslist}">
                            <td>${orders1.oid}</td>
                            <td style="text-align: center">
                                <c:if test="${orders1.ogimgpath==''}">
                                    <img src="${pageContext.request.contextPath}/static/images/white1.jpg"
                                         alt="图片加载失败">
                                </c:if>
                                <c:if test="${orders1.ogimgpath!=''}">
                                    <img src="${orders1.ogimgpath}"
                                         alt="图片加载失败">
                                </c:if>
                                <br>
                                    ${orders1.ogname}<br>
                                ￥${orders1.oprice}
                            </td>
                            <td>
                                <c:if test="${orders1.ogdetail==''}">
                                    （无）
                                </c:if>
                                <c:if test="${orders1.ogdetail!=''}">
                                    ${orders1.ogdetail}
                                </c:if>
                            </td>
                            <td>
                                    ${orders1.otime}
                            </td>
                            <td>
                                卖家：${orders1.osname}<br>
                                交易地点：${orders1.oposition}<br>
                                我的留言：
                                <c:if test="${orders1.onote==''}">
                                    （无）
                                </c:if>
                                <c:if test="${orders1.onote!=''}">
                                    ${orders1.onote}
                                </c:if>
                            </td>
                            <td>${orders1.ostatus}</td>
                            <td><a class="deleteOrder" href="deleteOrder?oid=${orders1.oid}">删除</a><br>
                        </tr>
                        </c:forEach>
                        <script>
                            let deleteOrder = document.getElementsByClassName("deleteOrder");

                            for (let i = 0; i < deleteOrder.length; i++) {
                                deleteOrder[i].onclick = function () {
                                    //layui的confirm点击后不知道为啥直接自动点是，暂时不用
                                    // layer.confirm('is not?', {icon: 3, title:'提示'}, function(index){
                                    //     layer.close(index);
                                    // });
                                    return confirm("确认删除此订单？");
                                }
                            }
                        </script>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <%-- 我卖出的 --%>
        <div class="layui-tab-item">
            <div class="layui-tab-item layui-show">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 25px">
                    <legend style="margin-left: 50px;">我卖出的</legend>
                </fieldset>

                <div class="layui-row">
                    <div class="layui-col-md10">
                        <table class="layui-table">
                            <colgroup>
                                <col width="50">
                                <col width="200">
                                <col width="300">
                                <col width="180">
                                <col width="300">
                                <col width="100">
                                <col width="80">
                                <col width="80">
                            </colgroup>
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>商品</th>
                                <th>商品描述</th>
                                <th>交易时间</th>
                                <th>交易详情</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <c:if test="${orderslist1.size() == 0}">
                                    <td colspan="7" style="text-align: center;height: 100px;">还没有卖过商品哦~</td>
                                </c:if>
                                <c:forEach var="orders1" items="${orderslist1}">
                                <td>${orders1.oid}</td>
                                <td style="text-align: center">
                                    <c:if test="${orders1.ogimgpath==''}">
                                        <img src="${pageContext.request.contextPath}/static/images/white1.jpg"
                                             alt="图片加载失败">
                                    </c:if>
                                    <c:if test="${orders1.ogimgpath!=''}">
                                        <img src="${orders1.ogimgpath}"
                                             alt="图片加载失败">
                                    </c:if>
                                    <br>
                                        ${orders1.ogname}<br>
                                    ￥${orders1.oprice}
                                </td>
                                <td>
                                    <c:if test="${orders1.ogdetail==''}">
                                        （无）
                                    </c:if>
                                    <c:if test="${orders1.ogdetail!=''}">
                                        ${orders1.ogdetail}
                                    </c:if>
                                </td>
                                <td>
                                        ${orders1.otime}<br>
                                </td>
                                <td>
                                    买家：${orders1.obname}<br>
                                    交易地点：${orders1.oposition}<br>
                                    买家留言：
                                    <c:if test="${orders1.onote==''}">
                                        （无）
                                    </c:if>
                                    <c:if test="${orders1.onote!=''}">
                                        ${orders1.onote}
                                    </c:if>
                                </td>
                                <td>${orders1.ostatus}</td>
                                <td><a class="deleteOrder" href="deleteOrder?oid=${orders1.oid}">删除</a><br>
                                </td>
                            </tr>
                            </c:forEach>
                            <script>
                                let deleteOrder = document.getElementsByClassName("deleteOrder");

                                for (let i = 0; i < deleteOrder.length; i++) {
                                    deleteOrder[i].onclick = function () {

                                        return confirm("确认删除此订单？");

                                    }
                                }
                            </script>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>



</body>
</html>
